/*r
 * bill_cfg.h
 *
 *  Created on: Dec 13, 2013
 *      Author: killerg
 */

#ifndef BILL_CFG_H_
#define BILL_CFG_H_


#include "share/cfg_file.h"

struct bill_cfg_t {
    bool init(const char* prefix) {
        cfg_file_t file;
        if (!file.load("bill.txt", prefix))
            return false;

        ListenServerIp       = file.get_str("listen_server_ip", "0.0.0.0");
        ListenServerPort     = file.get_int("listen_server_port", 8002);
        ListenConsoleIp      = file.get_str("listen_console_ip", "0.0.0.0");
        ListenConsolePort    = file.get_int("listen_console_port", 9008);
        HttpListenPort       = file.get_int("http_listen_port", 8080);
        DbHost               = file.get_str("db_host", "");
        DbBucket             = file.get_str("db_bucket", "" );
        OrderPerSec          = file.get_int("order_per_sec", 5 );
        Rate	             = file.get_int("rate", 1 );

        if (DbHost.empty()
         || DbBucket.empty())
            return false;

        return true;
    }
    void destroy() {
    }

    std::string ListenServerIp;
    int32_t ListenServerPort;

    std::string ListenConsoleIp;
    int32_t ListenConsolePort;

    int32_t HttpListenPort;

    std::string DbHost;
    std::string DbBucket;
    int32_t OrderPerSec;
    int32_t Rate;
};



#endif /* BILL_CFG_H_ */
